package com.personal.book.service.impl;

import java.util.List;

import com.personal.book.dao.impl.BookTypeDaoImpl;
import com.personal.book.entity.BookType;
import com.personal.book.entity.Users;
import com.personal.book.service.BookTypeService;
import com.personal.tools.PageData;
/**
 * 图书类别实现类
 * @author 姬
 *
 */
public class BookTypeServiceImpl implements BookTypeService {

	BookTypeDaoImpl btdi = new BookTypeDaoImpl();
	//添加图书类别
	@Override
	public boolean Add(BookType booktype) {
		// TODO Auto-generated method stub
		if (booktype == null) {
			return false;
		}
		// 先查询,判断是否存在"同名"的图书类别名
		BookType bt = btdi.getBookTypeByName(booktype.getTypeName());
		if (bt != null) {
			// 数据库有记录，直接返回false
			return false;
		}
		// 如果没有记录,那么调用添加的方法
		return btdi.Add(booktype);
	}

	//根据图书类别名精准查询
	@Override
	public BookType getBookTypeByName(String typeName) {
		// TODO Auto-generated method stub
		return btdi.getBookTypeByName(typeName);
	}
	
	//根据图书类别名精准查询
		@Override
		public BookType getBookTypeById(int typeId) {
			// TODO Auto-generated method stub
			return btdi.getBookTypeById(typeId);
		}

	
	//修改图书类别信息
	@Override
	public boolean Update(BookType booktype) {
		// TODO Auto-generated method stub
		return btdi.Update(booktype);
	}

	
	//分页模糊查询
	@Override
	public PageData<BookType> getBookTypeByKeyWord(int page, int pageSize, String keyword) {
		// TODO Auto-generated method stub
		return btdi.getBookTypeByKeyWord(page, pageSize, keyword);
	}

	//删除图书类别
	@Override
	public boolean Del(int typeId) {
		// TODO Auto-generated method stub
		return btdi.Del(typeId);
	}

	@Override
	public List<BookType> getBookTypeInfo() {
		// TODO Auto-generated method stub
		return btdi.getBookTypeInfo();
	}
	
}
